﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Atomic.Permission.Entities;
using NHibernate.Criterion;
using NHibernate.Linq;
using System.Linq.Expressions;
using Atomic.Db;
using Atomic.Common;
using Atomic.Permission.DAL;

namespace Atomic.Permission.BLL
{
    public class RoleFormFunBLL : ErrorImpl, IRoleFormFun
    {
        public bool Add(RoleFormFunEntity entity)
        {
            RoleFormFunDAL dal = new RoleFormFunDAL();
            if (dal.Exist(m=>m.RoleID==entity.RoleID && m.FormID==entity.FormID && m.FunID==entity.FunID))
            {
                Error = new ErrorResult()
                {
                    Message="角色功能权限已存在"
                };
                return false;
            }
            else
            {
                dal.Add(entity);
                return true;
            }
        }

        public bool Remove(int id)
        {
            RoleFormFunDAL dal = new RoleFormFunDAL();
            dal.Remove(id);
            return true;
        }
        
        public List<RoleFormFunEntity> GetList(Expression<Func<RoleFormFunEntity, bool>> predicate = null)
        {
            RoleFormFunDAL dal = new RoleFormFunDAL();
            return dal.GetList(predicate);
        }
    }
}
